ARCH := $(shell uname -i)
UNAME := $(shell uname -r)

ifeq ($(KERNEL_BUILD_PATH),)
	KERNEL_BUILD_PATH := /lib/modules/$(UNAME)/build
endif

ifneq ($(KERNELRELEASE),)
	TARGET := debug_printf
	obj-m = $(TARGET).o

	ccflags-y += -I$(PWD) -Wuninitialized

	$(TARGET)-objs = main.o
	
else
    ifeq ($(KERNEL_BUILD_PATH),)
        KERNEL_BUILD_PATH=/lib/modules/$(UNAME)/build
    endif
    MOD_PATH := $(shell pwd)
    default:
	$(MAKE) -C $(KERNEL_BUILD_PATH) M=$(MOD_PATH) modules

    clean:
	    rm -rf *.o *.mod.c *.mod.o *.mod *.ko* Module.symvers modules.order .*.cmd
endif
